package com.seocoo.worker.user.account.model;

import com.seocoo.worker.base.http.BasePageRsp;
import com.seocoo.worker.base.http.BaseRsp;
import com.seocoo.worker.user.account.entity.EDeposit;
import com.seocoo.worker.user.account.entity.EDepositDesc;
import com.seocoo.worker.user.account.model.req.ReqDeposit;
import com.seocoo.worker.user.account.model.req.ReqDepositApply;
import com.seocoo.worker.user.account.model.req.ReqDepositList;
import com.sfh.lib.HandleException;
import com.sfh.lib.IResult;
import com.sfh.lib.IResultSuccess;
import com.sfh.lib.mvvm.BaseViewModel;

public class DepositModel extends BaseViewModel {

    /***
     * 提现查询
     */
    public void queryDeposit(){
        this.execute(true, new ReqDeposit(), new IResultSuccess<BaseRsp<EDeposit>>() {
            @Override
            public void onSuccess(BaseRsp<EDeposit> eDepositBaseRsp) throws Exception {
                if (eDepositBaseRsp.success()){
                    setValue("onDepositSuccess",eDepositBaseRsp.getData());
                }else{
                    showDialogToast(eDepositBaseRsp.getMsg());
                }
            }
        });
    }

    /***
     * 提现
     */
    public void depositApply(ReqDepositApply req){
        this.execute(false, req, baseRsp -> {
            if (baseRsp.success()){
                showToast(baseRsp.getMsg());
                setValue("onDepositApply");
            }else{
                showDialogToast(baseRsp.getMsg());
            }
        });
    }

    public void queryList(int nowPage){
        this.execute(new ReqDepositList(nowPage), new IResult<BasePageRsp<EDepositDesc>>() {
            @Override
            public void onFail(HandleException e) {
                setValue("onPageSuccess");
            }

            @Override
            public void onSuccess(BasePageRsp<EDepositDesc> eIntgralBasePageRsp) throws Exception {
                setValue("onPageSuccess",eIntgralBasePageRsp);
            }
        });
    }
}
